RO
pedido

[Npc] Npc Teleporter Por Storage

Por romeu23, 24 de jul. de 2012 em Scripts

valendo rep+
script
26
3.5k
romeu23R
24 de julho de 2012 às 21:01

Presciso de um script que o Npc teleporta apenas players que tiverem uma das 2 Storages (7714 e 7715)

 

Valendo REP+

lukas13onL
24 de julho de 2012 às 21:05

Pronto di update agora ele vai teleportar quando tiver o storage.

 

Va em npc/scripts e crie um arquivo itemtravel.lua e bote isto dentro:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local pos = {x=152,y=58,z=7} -------------- Pos para onde o player sera levado
local storageid = 2468 ----------------- Id do storage

function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)		end
function onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)		end
function onCreatureSay(cid, type, msg)		npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()				npcHandler:onThink()				end

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then
	return false
end

if msgcontains(msg, "offer") or msgcontains(msg, "help") then
	selfSay("Eu posso te levar a TAL lugar por um "..getstorageNameById(storageid).." item, fale {travel} se quizer viajar.", cid)
	talkState[cid] = 0
elseif msgcontains(msg, 'travel') then
   if doPlayerStorageid(cid, storageid, 1) then
	selfSay("Boa viagem.", cid)
 doTeleportThing(cid, pos)
 else
 selfSay("Voce nao tem acesso.", cid)
 end
 end
 return TRUE  
 end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Depois crie um arquivo NOMEDONPC.lua e bote isto dentro:

 

<npc name="NOMEDONPC" script="data/npc/scripts/itemtravel.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
	<parameters>
			<parameter key="message_greet" value="Ola. Para mais informacoes de meus servicos diga {offer}." />
			<parameter key="message_farewell" value="Tchau." />
			<parameter key="message_walkaway" value="Tchau." />
	</parameters>
</npc>

NÃO ESQUEÇA DE CONFIGURAR!

 

 

 

FONTE: LINK

Editado Julho 24 por HarpiaLOOK

SkyLighS
24 de julho de 2012 às 21:09

Editei aki pra você nao testei pq to sem ot em casa

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=921,y=714,z=7}
function onCreatureAppear(cid)				  npcHandler:onCreatureAppear(cid)				end
function onCreatureDisappear(cid)			   npcHandler:onCreatureDisappear(cid)			 end
function onCreatureSay(cid, type, msg)		  npcHandler:onCreatureSay(cid, type, msg)		end
function onThink()							  npcHandler:onThink()							end
function creatureSayCallback(cid, type, msg)
	if (not npcHandler:isFocused(cid)) then
			return false
	end
	if msgcontains(msg, "quest") or msgcontains(msg, "help") then
			selfSay("Eu posso te levar a um lugar por um "..getItemNameById(itemid).." fale {travel} se quiser viajar.", cid)
			talkState[cid] = 0
	elseif msgcontains(msg, 'travel') then
	   selfSay("Boa viagem.", cid)
	 doTeleportThing(cid, pos)
	 end
    getPlayerStorageValue(cid,7714)
    getPlayerStorageValue(cid,7715)
	 selfSay("Voce Nao Tem As storage 7714 e 7715.", cid)
	 return true
	 end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Bem eu nao sabia se era pra viajar e tirar o item ou se era pra viajar so se voce tivesse o item mas nao removesse, caso nao seja isso que voce queira me fale que eu tiro.

 

Va em npc/scripts e crie um arquivo itemtravel.lua e bote isto dentro:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

local pos = {x=152,y=58,z=7} -------------- Pos para onde o player sera levado
local itemid = 2468 ----------------- Id do item que vai ser removido do player

function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)		end
function onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)		end
function onCreatureSay(cid, type, msg)		npcHandler:onCreatureSay(cid, type, msg)	end
function onThink()				npcHandler:onThink()				end

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then
	return false
end

if msgcontains(msg, "offer") or msgcontains(msg, "help") then
	selfSay("Eu posso te levar a TAL lugar por um "..getItemNameById(itemid).." item, fale {travel} se quizer viajar.", cid)
	talkState[cid] = 0
elseif msgcontains(msg, 'travel') then
   if doPlayerRemoveItem(cid, itemid, 1) then
	selfSay("Boa viagem.", cid)
 doTeleportThing(cid, pos)
 else
 selfSay("Voce nao tem o item nescessario.", cid)
 end
 end
 return TRUE  
 end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Depois crie um arquivo NOMEDONPC.lua e bote isto dentro:

 

<npc name="NOMEDONPC" script="data/npc/scripts/itemtravel.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
	<parameters>
			<parameter key="message_greet" value="Ola. Para mais informacoes de meus servicos diga {offer}." />
			<parameter key="message_farewell" value="Tchau." />
			<parameter key="message_walkaway" value="Tchau." />
	</parameters>
</npc>

NAO SE ESQUEÇA DE CONFIGURAR O LOCAL E O ITEMID NO SCRIPT....

 

 

 

FONTE: LINK

 

Desculpe. mas ele quer um que que o player tenha storage nao de remover item

Editado Julho 24 por SkyLigh

lukas13onL
24 de julho de 2012 às 21:20

Troque o itemID por STORAGEID

-----------------------------------------

pode pega a script, ajeitei para você

Editado Julho 24 por HarpiaLOOK

romeu23R
24 de julho de 2012 às 22:30

estou testando os scripts aqui e ja edito o post@@

 

nao esta dando , o player nao tem a storage e está sendo teleportado do mesmo jeito !

 

EDIT nos dois scripts!

lukas13onL
24 de julho de 2012 às 22:38

Okay agora editei tente agora.

SkyLighS
24 de julho de 2012 às 22:51

editei o meu era um erro técnico desculpe.

romeu23R
24 de julho de 2012 às 23:11

Tipo @harpialok , eu queria que fosse 2 storages

 

e @Skylight , o player tem a storage e tal, mas na hora que ele fala pra ir o npc nao teleporta ;s

 

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

local talkState = {}

local pos = {x=160,y=54,z=7}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end

function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end

function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)

if (not npcHandler:isFocused(cid)) then

return false

end

if msgcontains(msg, "") or msgcontains(msg, "help") then

 

talkState[cid] = 0

elseif msgcontains(msg, '') then

selfSay("Good luck in war!", cid)

doTeleportThing(cid, pos)

end

getPlayerStorageValue(cid,13540)

getPlayerStorageValue(cid,13540)

selfSay("Sorry, but your guild does not have access to a private area of war.", cid)

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

to usando este script ai e nao ta dando certo ;s

SkyLighS
24 de julho de 2012 às 23:12

agora eu acho que vai se n for amanha eu vo testar primeiro que vou baixar algum otserv

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local pos = {x=160,y=54,z=7}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if (not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, "") or msgcontains(msg, "help") then
talkState[cid] = 0
elseif msgcontains(msg, '') then
selfSay("Good luck in war!", cid)
doTeleportThing(cid, pos)
end
getPlayerStorageValue(cid,7714)
getPlayerStorageValue(cid,7715)
selfSay("Sorry, but your guild does not have access to a private area of war.", cid)
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

romeu23R
24 de julho de 2012 às 23:15

nao quer dar :/ , tava prescisando pra agora é urgente ! :S

lukas13onL
24 de julho de 2012 às 23:17

Valeu por ajeita minha script ;)

sou meio novatinho de vez enquando nos erra, mas aprendemos ;)

com nossos erros

romeu23R
24 de julho de 2012 às 23:27

nada ? ;s

lukas13onL
24 de julho de 2012 às 23:33

tente esse

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()  npcHandler:onThink() end
-- OTServ event handling functions end


-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'teleports'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Teleports of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, StorageIDcost=XXXX, destination = {x=117, y=53, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'depot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Depot of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, StorageIDcost=XXXX, destination = {x=131, y=54, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to \'Teleports\', \'Depot\' for just a small fee.'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

romeu23R
24 de julho de 2012 às 23:36

@ HarpiaLook , agora deu , mas mesmo sem storage ele é teleportado

lukas13onL
24 de julho de 2012 às 23:40

Tente agora assim:

troque os XXX

 

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)  npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
function onThink()  npcHandler:onThink() end
-- OTServ event handling functions end


-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'teleports'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Teleports of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, IfgetstorageID(XXXX), destination = {x=117, y=53, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
local travelNode = keywordHandler:addKeyword({'depot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Depot of City for 10 gold coins?'})
travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, level = 0, IfgetstorageID(XXXX), destination = {x=131, y=54, z=7} })
travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to \'Teleports\', \'Depot\' for just a small fee.'})

-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())

Editado Julho 24 por HarpiaLOOK